package com.qianyu.project.mapper.provider.smj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface smjPerformDao {
    //添加完工结算
    @Insert("insert into perform(id, apply_date, p_id, ctr_id, company_id, perform_name, contract_amount, penalty, withhold,  agree_amount, agree_upper, handler_id, settle_comment, attach_ids) " +
            "value(#{id}, #{apply_date}, #{p_id}, #{ctr_id}, #{company_id}, #{perform_name}, #{contract_amount}, #{penalty}, #{withhold},  #{agree_amount}, #{agree_upper}, #{handler_id}, #{settle_comment}, #{attach_ids})")
    void Addperform(String id,String apply_date, String p_id, String ctr_id, String company_id, String perform_name, String contract_amount, String penalty, String withhold, String agree_amount, String agree_upper, String handler_id, String settle_comment, String attach_ids);

    //添加工程量清单
    @Insert("insert into perform_work_list values(null,#{perform_id}, #{work_content}, #{unit}, #{work_count}, #{unit_price}, #{snumber}, #{hnumber}, #{sumnumber}, #{comment})")
    void Addworklist(String perform_id, String work_content, String work_count, String unit, String unit_price, String snumber, String hnumber, String sumnumber, String comment);

    //修改审批状态
    @Update("update perform set approve_status=#{approve_status} where id=#{id}")
    void UpdateApproveStatus(int approve_status, String id);

    //查询完工结算列表
    @SelectProvider(type=PerformProvider.class,method = "listPerform")
    IPage<Map<String, Object>> listPerform(IPage<Map<String, Object>> page, Map<String, String> params);

    //查询工程量清单
    @Select("select * from perform_work_list where perform_id =#{perform_id}")
    List<Map<String, Object>> getWorkList(String perform_id);

    //获取流程id
    @Select("select fid from form  where id=#{perform_id} and target ='perform'")
    String getFid(String perform_id);

    //获取审批流程
    @Select("select fa.*,fn.flowNodeName,su.user_realname from form_audit fa ,flow_node fn ,system_user su where fa.fid=#{fid} and fa.flowNodeId = fn.flowNodeId and fa.eid=su.id")
    List<Map<String, Object>> getfromaudit(String fid);
}
